import sys
import os
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QApplication, QMainWindow,QFileDialog,QWidget

import untitled

def open_img():
    fileName, fileType = QFileDialog.getOpenFileName(MainWindow,"选取文件", os.getcwd(),"*.jpg;;*.png;;All Files(*)")

    ui.img1.setPixmap(QPixmap(fileName))
def test():
    print("ok")
if __name__ == '__main__':
    app = QApplication(sys.argv)
    MainWindow = QMainWindow()
    ui = untitled.Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    ui.upimg.clicked.connect(open_img)

    sys.exit(app.exec_())